package com.TeamJigsaw.DanteTrail.Presenters;

import java.awt.CardLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import com.TeamJigsaw.DanteTrail.Debug.Debug;
import com.TeamJigsaw.DanteTrail.Models.Party;
import com.TeamJigsaw.DanteTrail.Views.MainViewFrame;
import com.TeamJigsaw.DanteTrail.Views.Interfaces.WagonViewInterface;

public class WagonViewController {
	
	Party party;
	MainViewFrame mainView;
	WagonViewInterface wagon;
	
	public WagonViewController(Party party, MainViewFrame mainView)
	{
		this.party = party;
		this.mainView = mainView;
		wagon = mainView.getWagonView();
		wagon.setAmmo(party.getAmmo());
		int axel = party.getAxels();
		if(axel <=2)
			wagon.setAxelsWorking(party.getAxels());
		else
			wagon.setAxelsWorking(2);
		wagon.setAxels(party.getAxels());
		
		wagon.setClothes(party.getClothes());
		wagon.setFood(party.getFood());
		wagon.setInventoryWeight(party.getWeight(), party.getMaxWeight());
		wagon.setOxen(party.getWagon().getOxenNo());
		int oxen = party.getWagon().getOxenNo();
		if(oxen <=2)
			wagon.setOxenWorking(oxen);
		else
			wagon.setOxenWorking(2);
		wagon.setTongues(party.getTongue());
		
		int tongue = party.getTongue();
				if(oxen <1)
					wagon.setTongueWorking(false);
				else
					wagon.setTongueWorking(true);
				
		wagon.setWheels(party.getWheels());
		
		int wheel = party.getWheels();
		if(wheel <=4)
			wagon.setWheelsWorking(wheel);
		else
			wagon.setWheelsWorking(4);
		ActionListener trailListen = new TrailListener();
		wagon.setTrailListener(trailListen);
		
		
		
	}
	
	private class TrailListener implements ActionListener{

		@Override
		public void actionPerformed(ActionEvent e) {
			((CardLayout) mainView.getContentPane().getLayout()).show(mainView.getContentPane(), "Game");
			mainView.setTitle("Trail");
			GameViewController gvc = new GameViewController(party, mainView);
			
		}
		
	}

}
